<template>
	<form-frame v-model="visible" title="库按钮" width="540" :type="formType" :loading="btnLoading" @submit="handleSubmitForm()">
		<el-form ref="form" size="medium" :model="formData" :rules="formRules" label-width="80px" v-loading="loading">
			<el-form-item label="按钮名称" prop="name">
				<el-input type="input" v-model="formData.name"></el-input>
			</el-form-item>
			<el-form-item label="按钮类别" prop="type">
				<sw-dict-select v-model="formData.type" dict-name="DISK_ROLE_BUTTON_TYPE" placeholder="按钮类别"></sw-dict-select>
			</el-form-item>
			<el-form-item label="描述" prop="content">
				<el-input type="textarea" v-model="formData.content"></el-input>
			</el-form-item>
			<el-form-item label="默认选中" prop="isSelect">
				<el-switch v-model="formData.isSelect" active-value="1" inactive-value="2"></el-switch>
			</el-form-item>
		</el-form>
	</form-frame>
</template>

<script>
import formMixins from '@/views/common/formMixins';
import { queryLibraryButton, addedLibraryButton, updateLibraryButton } from '@/api/platform/tbRoleButton';
export default {
	mixins: [formMixins],
	data() {
		return {
			formRules: {
				name: [{ required: true, message: '请输入按钮名称', trigger: 'blur' }],
				type: [{ required: true, message: '请选择按钮类型', trigger: 'change' }]
			}
		};
	},
	methods: {
		//获取数据详情
		getDataDetail() {
			this.getFormDetail(queryLibraryButton, this.dataId);
		},

		//提交表单
		handleSubmitForm() {
			let params = { ...this.formData };
			this.handleSubmitFunction(params, addedLibraryButton, updateLibraryButton);
		}
	}
};
</script>

<style lang="scss" scoped>
.lib_button_form {
	flex: 1;
	padding: 10px 10px 0 0;
}
</style>
